package com.ruibang.glass.produce.controller.jjs;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.frequencycontrol.annotation.FrequencyControl;
import com.ruibang.glass.produce.constant.Constants;
import com.ruibang.glass.produce.domain.req.BcpCleanRoomRecordReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruibang.glass.produce.service.ProduceBcpCleanRoomRecordService;
import com.ruibang.glass.produce.entity.ProduceBcpCleanRoomRecord;

import javax.servlet.http.HttpServletResponse;


/**
 * <p>
 * 生产-洁净室-半成品洁净室环境记录 前端控制器
 * </p>
 *
 * @author 宋锦康
 * @since 2024-03-11
 */
@RestController
@RequestMapping("/api/glass/produce/jjs/bcpCleanRoomRecord")
@Api(value = "生产-洁净室-半成品洁净室环境记录控制器", tags = {"生产-洁净室-半成品洁净室环境记录接口"})
public class ProduceBcpCleanRoomRecordController {

    @Autowired
    private ProduceBcpCleanRoomRecordService produceBcpCleanRoomRecordService;

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "获取生产-洁净室-半成品洁净室环境记录", notes = "获取生产-洁净室-半成品洁净室环境记录")
    public ResultBody getById(@PathVariable(value = "id") String id) {
        return ResultBody.success(produceBcpCleanRoomRecordService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增生产-洁净室-半成品洁净室环境记录", notes = "新增生产-洁净室-半成品洁净室环境记录")
    public ResultBody save(@RequestBody ProduceBcpCleanRoomRecord produceBcpCleanRoomRecord) {
        produceBcpCleanRoomRecord.setIsDelete(Constants.ZERO_STR);
        produceBcpCleanRoomRecordService.save(produceBcpCleanRoomRecord);
        return ResultBody.success();
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改生产-洁净室-半成品洁净室环境记录", notes = "修改生产-洁净室-半成品洁净室环境记录")
    public ResultBody updateById(@RequestBody ProduceBcpCleanRoomRecord produceBcpCleanRoomRecord) {
        produceBcpCleanRoomRecordService.updateById(produceBcpCleanRoomRecord);
        return ResultBody.success();
    }

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询生产-洁净室-半成品洁净室环境记录", notes = "分页列表查询生产-洁净室-半成品洁净室环境记录")
    public ResultBody<IPage<ProduceBcpCleanRoomRecord>> pageQuery(@RequestBody BcpCleanRoomRecordReq bcpCleanRoomRecordReq) {
        return ResultBody.success(produceBcpCleanRoomRecordService.pageQuery(bcpCleanRoomRecordReq));
    }

    @DeleteMapping("/deleteById/{id}")
    @ApiOperation(value = "通过ID删除生产-洁净室-半成品洁净室环境记录", notes = "通过ID删除生产-洁净室-半成品洁净室环境记录")
    public ResultBody delete(@PathVariable(value = "id") String id) {
        produceBcpCleanRoomRecordService.delete(id);
        return ResultBody.success();
    }

    @PostMapping("/export")
    @ApiOperation(value = "数据导出")
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 4, target = FrequencyControl.Target.IP)
    public void export(@RequestBody BcpCleanRoomRecordReq bcpCleanRoomRecordReq, HttpServletResponse response) {
        produceBcpCleanRoomRecordService.export(bcpCleanRoomRecordReq, response);
    }

}
